#ifndef __CLINKLIST_H__
#define __CLINKLIST_H__
#include "stdtypes.h"

class CLinkList
{
public:
	CLinkList();
	virtual ~CLinkList();
	
	int16  Count();
	void   AddData(void *data,int16 index = -1);
	void * GetData(int16 index);
	void   Remove(int16 index);
	void   RemoveAll();
private:
	void *          m_pList;
};

template <class T>
class CXList 
{
public:
	CXList();
	virtual ~CXList();
	
	int16  Count();
	void   AddData(T *data,int16 index = -1);
	T *    GetData(int16 index);
	void   Remove(int16 index);
	void   RemoveAll();
	void   Delete(int16 index);
	void   DeleteAll();
private:
	CLinkList *m_List;
};

template <class T>
CXList<T>::CXList()
{
	m_List = new CLinkList();
}

template <class T>
CXList<T>::~CXList()
{
	delete m_List;
}

template <class T>
int16 CXList<T>::Count()
{
	return m_List->Count();
}

template <class T>
void CXList<T>::AddData(T *data,int16 index)
{
	m_List->AddData(data, index);
}

template <class T>
T * CXList<T>::GetData(int16 index)
{
	return (T *)m_List->GetData(index);
}

template <class T>
void CXList<T>::Remove(int16 index)
{
	m_List->Remove(index);
}

template <class T>
void CXList<T>::RemoveAll()
{
	m_List->RemoveAll();
}

template <class T>
void CXList<T>::Delete(int16 index)
{
	delete GetData(index);
	m_List->Remove(index);
}

template <class T>
void CXList<T>::DeleteAll()
{
	int16 count = Count();
	for(int i=0;i<count;i++)
	{
		delete GetData(i);
	}
	m_List->RemoveAll();
}


#endif	// #ifndef __CLINKLIST_H__
